<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/content/variable.jsp" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <%@ include file="/content/head.jsp" %>
</head>
<body>
<div class="row">
    <div class="col-md-12">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">修改分类</h3>
            </div>
            <form id="addInfo" class="form-horizontal" role="form">
                <div class="box-body">
                    <div class="form-group">
                        <label for="channelId" class="col-sm-2 control-label">渠道号：</label>
                        <div class="col-sm-8 ">
                            <input type="text" id="channelId" class="form-control" name="channelId"
                                 value="${obj.channelId}"  placeholder="渠道号名称">
                        </div>
                    </div>
                    <br>
                    <div class="form-group">
                        <label  class="col-sm-2 control-label">视频分类：</label>
                        <div class="col-sm-8 ">
                            <label>
                                <input type="radio"checked name="channelType" value="1"
                                       <c:if test="${obj.channelType eq 1}">checked</c:if>
                                       class="flat-red">白包
                            </label>
                            <label>
                                <input type="radio"  name="channelType" value="2"
                                       <c:if test="${obj.channelType eq 2}">checked</c:if>
                                       class="flat-red">黑包
                            </label>
                        </div>
                    </div>
                    <br>
                    <input type="hidden" name="id" value="${obj.id}">
                    <div class="col-md-offset-5 col-md-9">
                        <button type="submit" class="btn btn-success">确定</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- /.row -->
<%@ include file="/content/js.jsp" %>
<script type="text/javascript">
    $(function () {
        $('#addInfo').bootstrapValidator({
            message: '此值无效',
            fields: {
                channelId: {
                    message: '渠道号验证失败',
                    validators: {
                        notEmpty: {
                            message: '渠道号不能为空'
                        }
                    }
                }
            }
        }).on('success.form.bv', function (e) {//点击提交之后
            e.preventDefault();
            var $form = $(e.target);
            var bv = $form.data('bootstrapValidator');
            saveInfo();
        });
    })
        function saveInfo() {
            $.post("<%=path%>/channelSwitch/edit",
                $("#addInfo").serialize()
                , function (data) {
                    if (data.missage == "success") {
                        modalMsg("更新成功", "success");
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else if (data.missage == "error") {
                        modalMsg("修改失败", "error");
                    } else {
                        modalMsg("修改失败", "error");
                    }
                }
            );
        }

</script>
</body>
</html>